<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/DTD/strict.dtd">

<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
	<title>DOMAssistantEvents module - DOM Assistant, the modular lightweight JavaScript library</title>
	<style type="text/css">
		@import url("css/domassistant.css");
	</style>
	<!--[if lt IE 7]>
		<link rel="stylesheet" href="css/ie.css" type="text/css">
	<![endif]-->
</head>

<body>
	
	<div id="container">
		<div id="inner-container">
			<div id="main-content">
				<h1><a href="index.htm"><span></span>DOMAssistant</a></h1>
				<h2>DOMAssistantEvents module</h2>
				<p>Here you will find a general documentation for the DOMAssistantEvents module.</p>
				<h3 id="domass-module">Module documentation</h3>
				<p>The DOMAssistantEvents module offers various methods for adding and removing handlers for one or several events on an element, It also contains functionality for stopping default actions and bubbling of events. The methods are:</p>
				
				<h4>Methods</h4>
				<ul>
					<li><a href="#addevent">addEvent</a></li>
					<li><a href="#removeevent">removeEvent</a></li>
					<li><a href="#preventdefault">preventDefault</a></li>
					<li><a href="#cancelbubble">cancelBubble</a></li>
				</ul>
				
				<h4 id="addevent"><code>addEvent(evt, func)</code></h4>
				<p>Adds an event handler to the current element. Multiple event handlers are supported, and the receiving funtion will have an event object reference and a <code>this</code> reference to the element it occurred on, no matter what web browser. For accessibility reasons, please make sure to only apply click events to elements that can handle them without JavaScript enabled.</p>
				<h5>Parameters</h5>
				<dl>
					<dt>evt</dt>
					<dd>Event to apply, specified as a string, without the "on" prefix.</dd>
					<dt>func</dt>
					<dd>Function to handle the event, specified as a function reference (without parentheses) or an anonymous function.</dd>
				</dl>
				
				<h5>Example calls</h5>
<pre><code>
// Adds a click event to the element named "get-listing"
$("container").addEvent("click", getListing);
// Adds a click event to the element named "get-listing"
$("container").addEvent("click", function (){
	alert("Hello darling!");
});
</code></pre>
				
				<h4 id="removeevent"><code>removeEvent(evt, func)</code></h4>
				<p>Removes an event handler from the current element. Works only for function references, and not anonymous functions.</p>
				<h5>Parameters</h5>
				<dl>
					<dt>evt</dt>
					<dd>Event to remove, specified as a string, without the "on" prefix.</dd>
					<dt>func</dt>
					<dd>Function to stop from handling the event, specified as a function reference (without parentheses).</dd>
				</dl>
				
				<h5>Example calls</h5>
<pre><code>
// Removes a click event from the element named "get-listing"
$("container").removeEvent("click", getListing);
</code></pre>

				<h4 id="preventdefault"><code>preventDefault(evt)</code></h4>
				<p>Prevents the default action of an event. Can be called from any function, and is not a method of any element.</p>
				<h5>Parameters</h5>
				<dl>
					<dt>evt</dt>
					<dd>Event to prevent the default action of.</dd>
				</dl>
				
				<h5>Example calls</h5>
<pre><code>
// Prevents the default behavior of an event
DOMAssistant.preventDefault(eventReference);
</code></pre>

				<h4 id="cancelbubble"><code>cancelBubble(evt)</code></h4>
				<p>Cancels the bubbling of an event. Can be called from any function, and is not a method of any element.</p>
				<h5>Parameters</h5>
				<dl>
					<dt>evt</dt>
					<dd>Event to cancel the bubbling of.</dd>
				</dl>
				
				<h5>Example calls</h5>
<pre><code>
// Cancels the bubbling of an event
DOMAssistant.cancelBubble(eventReference);
</code></pre>
			
			</div>
			
			<div id="navigation">
				<div id="navigation-inner">
					<p><em>Current version is 2.0, released September 19th 2007.</em></p>
					<p><em>November 8th 2007 update: <code>elmsByAttribute</code> update. <a href="Release-notes.txt">Release notes</a></em></p>
					<h3>Information</h3>
					<ul>
						<li><a href="index.htm">Introduction</a></li>
						<li><a href="compatibility.htm">Compatibility</a></li>
						<li><a href="demo.htm">Demo</a></li>
					</ul>
				
					<h3>Module documentation</h3>
					<ul>
						<li><a href="modules-domassistant.htm">DOMAssistant</a></li>
						<li><a href="modules-domassistant-ajax.htm">DOMAssistantAJAX</a></li>
						<li><a href="modules-domassistant-content.htm">DOMAssistantContent</a></li>
						<li><a href="modules-domassistant-css.htm">DOMAssistantCSS</a></li>
						<li><a href="modules-domassistant-events.htm" class="selected">DOMAssistantEvents</a></li>						
						<li><a href="modules-domassistant-load.htm">DOMAssistantLoad</a></li>
						<li><a href="documentation/DOMAssistant-documentation.pdf">Complete documentation (PDF)</a></li>
						<li><a href="documentation/DOMAssistant-diagram.pdf">Diagram with all modules and methods (PDF)</a></li>
					</ul>
	
					<h3>Downloads</h3>
					
					<h4>Complete files with all modules</h4>
					<ul>
						<li><a href="http://code.google.com/p/domassistant/downloads/detail?name=DOMAssistantCompressed-2.0.js&amp;can=2&amp;q=#makechanges" title="Download DOMAssistantCompressed.js at Google code">Compressed (10.5 kb)</a></li>
						<li><a href="http://code.google.com/p/domassistant/downloads/detail?name=DOMAssistantComplete-2.0.js&amp;can=2&amp;q=#makechanges" title="Download DOMAssistantComplete.js at Google code">Uncompressed (15.7 kb)</a></li>
					</ul>
					
					<h4>Module by module</h4>
					<ul>
						<li><a href="http://code.google.com/p/domassistant/downloads/detail?name=DOMAssistant-2.0-modules.zip&amp;can=2&amp;q=#makechanges" title="Download DOMAssistant-2.0-modules.zip at Google code">All DOMAssistant modules ZIP file (8.8 kb)</a></li>
						<li><a href="http://code.google.com/p/domassistant/downloads/detail?name=DOMAssistant-2.0.js&amp;can=2&amp;q=" title="Download DOMAssistant.js at Google code">DOMAssistant (4.2 kb)</a></li>
						<li><a href="http://code.google.com/p/domassistant/downloads/detail?name=DOMAssistantAJAX-2.0.js&amp;can=2&amp;q=" title="Download DOMAssistantAJAX.js at Google code">DOMAssistantAJAX (1.4 kb)</a></li>
						<li><a href="http://code.google.com/p/domassistant/downloads/detail?name=DOMAssistantContent-2.0.js&amp;can=2&amp;q=" title="Download DOMAssistantContent.js at Google code">DOMAssistantContent (3.3 kb)</a></li>
						<li><a href="http://code.google.com/p/domassistant/downloads/detail?name=DOMAssistantCSS-2.0.js&amp;can=2&amp;q=" title="Download DOMAssistantCSS.js at Google code">DOMAssistantCSS (2.5 kb)</a></li>
						<li><a href="http://code.google.com/p/domassistant/downloads/detail?name=DOMAssistantEvents-2.0.js&amp;can=2&amp;q=" title="Download DOMAssistantEvents.js at Google code">DOMAssistantEvents (2.2 kb)</a></li>
						<li><a href="http://code.google.com/p/domassistant/downloads/detail?name=DOMAssistantLoad-2.0.js&amp;can=2&amp;q=" title="Download DOMAssistantLoad.js at Google code">DOMAssistantLoad (2.1 kb)</a></li>
					</ul>
								
					<h3>Comments/updates</h3>
					<ul>
						<li><a href="http://www.robertnyman.com/2007/01/25/domass-the-dom-assistant/">First release blog post with comments and information</a></li>
						<li><a href="http://www.robertnyman.com/2007/09/20/releasing-domassistant-20-chainability-ajax-module-domready-xpath-and-more/">Version 2.0 release blog post with comments and information</a></li>
					</ul>
					
					<h3>Sign up for updates</h3>
					<p>Send an e-mail to domassistant [at] robertnyman [dot] com to verify your e-mail address and receive information about updates</p>
				
					<h3>Contact</h3>
					<ul>
						<li><a href="http://www.robertnyman.com/about">Contact the author</a></li>
					</ul>
				</div>	
				
			</div>		
		</div>
		
		<div id="footer">
			Created by Robert Nyman, <a href="http://www.robertnyman.com">http://www.robertnyman.com</a>
		</div>
		
	</div>
	
	<!-- Google Analytics code -->
	<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>
	<script type="text/javascript">
		_uacct = "UA-56164-1";
		urchinTracker();
	</script>
	
	<!-- Start of StatCounter Code -->
	<script type="text/javascript">
	<!-- 
	var sc_project=593937; 
	var sc_partition=4; 
	var sc_security="175a1fec"; 
	//-->
	</script>
		
	<script type="text/javascript" src="http://www.statcounter.com/counter/counter_xhtml.js"></script><noscript><div class="statcounter"><a class="statcounter" href="http://www.statcounter.com/"><img class="statcounter" src="http://c5.statcounter.com/counter.php?sc_project=593937&amp;java=0&amp;security=175a1fec" alt="free geoip" /></a></div></noscript>
	<!-- End of StatCounter Code -->
	
	<!-- gVisit code -->
	<script type="text/javascript" src="http://www.gvisit.com/record.php?sid=de2c9dfeacdc0124bdb3fe3eab766832"></script>
	
</body>
</html>